<h1>Editing rooms</h1>

<% form_for(@room) do |f| %>
  <%= f.error_messages %>

   <p>
    <%= f.label :code %>
    <%= f.text_field :code %>
  </p>
  <p>
    <%= f.label :stock %>
    <%= f.check_box :stock %>
  </p>
  <p>
    <%= f.label :capacity %>
    <%= f.text_field :capacity %>
  </p>
  <p>
    <%= f.label :company_id %>
	<% companies = Company.all %>
    <%= f.select(:company_id, companies.collect {|c| [c.name, c.id] },:selected => @room.company_id, :include_blank => true)%>
  </p>
  <p>
  <h2>Networks :</h2>
  <table border="2">
  	<tr class="ui-state-default">
  	  <th>Available</th>
  	  <th>Belongs to me</th>
  	</tr>
  	<tr>
  	  <td id='trash_network'>
	     <% Network.all.each do |network| %>
      	   <%if !@room.networks.include?(network)%>
		     <%= render :partial => 'rooms/room_network', :locals => {:network => network}%>
      	   <%end%>
		 <% end %>
	  </td>
	  <td id='container_network'>
		<% Network.all.each do |network| %>
      	   <%if @room.networks.include?(network)%>
			  <%= render :partial => 'rooms/room_network', :locals => {:network => network}%>
			<%end%>
		<%end%>
	  </td>
	</tr>
  </table>
  <%= drop_receiving_element('trash_network',
    :accept => "dragable",
    :with   => "'network_id=' + (element.id.split('_').last()) + '&room_id=#{@room.id.to_s}'",
    :url    => {:action=>:delete_network}
  )%>
  <%= drop_receiving_element('container_network',
    :accept => "dragable",
    :with   => "'network_id=' + (element.id.split('_').last()) + '&room_id=#{@room.id.to_s}'",
    :url    => {:action=>:add_network}
  )%>
  </p>
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>

	<% link_to @room, :class => "ui-state-default ui-corner-all dialog_link" do %>
			<span class="ui-icon ui-icon-search"></span>View
	<% end %>&nbsp;
	<% link_to rooms_path, :class => 'ui-state-default ui-corner-all dialog_link' do %>
		<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span>Back
	<% end %>
